package com.hl.order.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.hl.order.domain.RefundGoodsSpec;
import com.hl.order.service.IRefundGoodsSpecService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 退款商品规格Controller
 * 
 * @author ruoyi
 * @date 2025-08-09
 */
@RestController
@RequestMapping("/refundGoodsSpec")
public class RefundGoodsSpecController extends BaseController
{
    @Autowired
    private IRefundGoodsSpecService refundGoodsSpecService;

    /**
     * 查询退款商品规格列表
     */
    @RequiresPermissions("order:refundGoodsSpec:list")
    @GetMapping("/list")
    public TableDataInfo list(RefundGoodsSpec refundGoodsSpec)
    {
        startPage();
        List<RefundGoodsSpec> list = refundGoodsSpecService.selectRefundGoodsSpecList(refundGoodsSpec);
        return getDataTable(list);
    }

    /**
     * 导出退款商品规格列表
     */
    @RequiresPermissions("order:refundGoodsSpec:export")
    @Log(title = "退款商品规格", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RefundGoodsSpec refundGoodsSpec)
    {
        List<RefundGoodsSpec> list = refundGoodsSpecService.selectRefundGoodsSpecList(refundGoodsSpec);
        ExcelUtil<RefundGoodsSpec> util = new ExcelUtil<RefundGoodsSpec>(RefundGoodsSpec.class);
        util.exportExcel(response, list, "退款商品规格数据");
    }

    /**
     * 获取退款商品规格详细信息
     */
    @RequiresPermissions("order:refundGoodsSpec:query")
    @GetMapping(value = "/{refundGoodsSpecId}")
    public AjaxResult getInfo(@PathVariable("refundGoodsSpecId") Long refundGoodsSpecId)
    {
        return success(refundGoodsSpecService.selectRefundGoodsSpecByRefundGoodsSpecId(refundGoodsSpecId));
    }

    /**
     * 新增退款商品规格
     */
    @RequiresPermissions("order:refundGoodsSpec:add")
    @Log(title = "退款商品规格", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RefundGoodsSpec refundGoodsSpec)
    {
        return toAjax(refundGoodsSpecService.insertRefundGoodsSpec(refundGoodsSpec));
    }

    /**
     * 修改退款商品规格
     */
    @RequiresPermissions("order:refundGoodsSpec:edit")
    @Log(title = "退款商品规格", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RefundGoodsSpec refundGoodsSpec)
    {
        return toAjax(refundGoodsSpecService.updateRefundGoodsSpec(refundGoodsSpec));
    }

    /**
     * 删除退款商品规格
     */
    @RequiresPermissions("order:refundGoodsSpec:remove")
    @Log(title = "退款商品规格", businessType = BusinessType.DELETE)
	@DeleteMapping("/{refundGoodsSpecIds}")
    public AjaxResult remove(@PathVariable Long[] refundGoodsSpecIds)
    {
        return toAjax(refundGoodsSpecService.deleteRefundGoodsSpecByRefundGoodsSpecIds(refundGoodsSpecIds));
    }
}
